/*
 * @Author: LIFM0623 1944099171@qq.com
 * @Date: 2024-01-11 17:28:46
 * @LastEditors: LIFM0623 1944099171@qq.com
 * @LastEditTime: 2024-01-16 10:22:29
 * @FilePath: \scene_back_nest\src\auth\auth.module.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Inject, Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from 'src/user/entities/user.entity';
import { PassportModule } from '@nestjs/passport';
import { UserModule } from 'src/user/user.module';
import { LocalStorage } from './local.strategy';
import { JwtStorage } from './jwt.strategy';


// const jwtModule = JwtModule.registerAsync({
//   imports: [ConfigModule],
//   useFactory: (configService: ConfigService) => {
//     return {
//       secret: configService.get('warSence', 'yssyyds'),
//       // signOptions: { expiresIn: '4h' },    // 将生成时间写入auth.service.ts 中
//     };
//   },
// });

@Module({
  imports: [TypeOrmModule.forFeature([User]), 
  JwtModule.registerAsync({
    imports: [ConfigModule], // 导入包含 ConfigService 的模块
    useFactory: (configService: ConfigService) => ({
      secret: configService.get('warSence', 'yssyyds'),
    }),
    inject: [ConfigService],
  }), UserModule, PassportModule],
  controllers: [AuthController],
  providers: [AuthService, LocalStorage, JwtStorage, ConfigService],
})
export class AuthModule { }
